package com.personal.service.Impl;

import com.personal.enums.CarouselEnum;
import com.personal.exception.ExceptionUtils;
import com.personal.mapper.CarouselMapper;
import com.personal.pojo.Carousel;
import com.personal.service.CarouselService;
import com.personal.service.HomeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Slf4j
public class CarouselServiceImpl implements CarouselService {

    @Autowired
    private CarouselMapper carouselMapper;

    /**
     * 查询所有轮播图
     * @param isShow
     * @return
     */
    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public List<Carousel> queryAllCarousel(Integer isShow) {
        log.info("开始执行查询所有轮播图接口");
        List<Carousel> carouselList = carouselMapper.queryAllCarousel(isShow);
        if (carouselList.isEmpty()){
            ExceptionUtils.error(CarouselEnum.CAROUSEL_LIST_IS_NULL);
        }
        return carouselList;
    }
}
